home *** CD-ROM | disk | FTP | other *** search
/ C & C++ Multimedia Cyber Classroom / C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso / src / fig19_04.jar / Ch19 / Fig19_04 / fig19_04.cpp
C/C++ Source or Header  |  1997-11-01  |  423b  |  18 lines

  1. // Fig. 19.4: fig19_04.cpp
  2. // Using the swap function to swap two strings
  3. #include <iostream>
  4. #include <string>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.    string first( "one" ), second( "two" );
  10.  
  11.    cout << "Before swap:\n first: " << first
  12.         << "\nsecond: " << second;
  13.    first.swap( second );
  14.    cout << "\n\nAfter swap:\n first: " << first
  15.         << "\nsecond: " << second << endl;
  16.     
  17.    return 0;
  18. }